#include "sgl_draw_icon.h"


void sgl_draw_icon(sgl_surf_t *surf, int x, int y, sgl_color_t color, sgl_color_t bg_color, sgl_icon_t *icon)
{
    const uint8_t *dot = icon->bitmap;
    for(int i = 0; i < icon->height; i++) {
        for(int j = 0; j < icon->width; j +=2) {
            sgl_draw_point(surf, x + j, y + i, sgl_color_mixer(color, bg_color, (((*dot)>>4)&0xF)*16));
            sgl_draw_point(surf, x + j + 1, y + i, sgl_color_mixer(color, bg_color, (((*dot))&0xF)*16));
            dot ++;
        }
    }
}


void sgl_draw_icon_transp(sgl_surf_t *surf, int x, int y, sgl_color_t color, sgl_color_t bg_color, sgl_icon_t *icon)
{
    const uint8_t *dot = icon->bitmap;
    for(int i = 0; i < icon->height; i++) {
        for(int j = 0; j < icon->width; j +=2) {
            if((((*dot)>>4)&0xF)*16 != 0) {
                sgl_draw_point(surf, x + j, y + i, sgl_color_mixer(color, bg_color, (((*dot)>>4)&0xF)*16));
                sgl_draw_point(surf, x + j + 1, y + i, sgl_color_mixer(color, bg_color, (((*dot))&0xF)*16));
            }
            dot ++;
        }
    }
}
